<?php
session_start();
define('ABSPATH', $_SERVER['DOCUMENT_ROOT'] . '/');
include(ABSPATH.'config.php');

$table = $_GET['table'];
$catId = $_GET['catid'];
$view = $_GET['view'];
$maxItems = $_GET['maxItems'];

if(isset($maxItems)) {
    $_SESSION['maxItems'] = $maxItems;
}
else {
    if(!isset($_SESSION['maxItems'])) {
        $_SESSION['maxItems'] = 4;
    }
}

if(isset($view)) {
    $_SESSION['viewMode'] = $view;
}
else {
    if(!isset($_SESSION['viewMode'])) {
        $_SESSION['viewMode'] = "default";
    }
}

include('./class.thumbBox.php');
$thumbBox = new thumbBox();
$portItem = $thumbBox->getProjects($table, $catId, $_SESSION['maxItems']);
?>

<div class="thumbBox">
    <?php foreach($portItem as $item) {
        if($_SESSION['viewMode'] == "default") {
            ?>

    <div class="portfolioItem">
        <div class="portfolioThumb">
            <img src="<?php print(DATA_PATH); ?>/images/portfolio/<?php print($item['thumb']); ?>" alt="<?php print($item['object'].' '.$item['client']); ?>" />
            <div class="overlayImage"><?php print($item['object'].' '.$item['client']); ?></div>
            <a <?php if($catId == 4) {print('class="youtube"');} ?> href="<?php print($item['url']); ?>" rel="external" title="<?php print($item['object'].' '.$item['client']); ?>">
                <span class="pictureframe"></span>
            </a>
        </div>
        <div class="itemBody">
            <p class="nomarg">
                <span class="bold">Client: </span> <?php print($item['client']); ?> <br />
                <span class="bold">Involvement: </span> <?php print($item['tasks']); ?> <br />
                <span class="bold">Date: </span> <?php print($item['time']); ?> <br />
                <!--<span class="bold">Summary: </span> <?php //print($item['summary']); ?> <br />-->
            </p>
        </div>
    </div>
        <?php
        }
        elseif($_SESSION['viewMode'] == "thumbs") {
            ?>
    <div class="portfolioThumb" style="margin:10px">
        <img src="<?php print(DATA_PATH); ?>/images/portfolio/<?php print($item['thumb']); ?>" alt="<?php print($item['object'].' '.$item['client']); ?>" />
        <div class="overlayImage"><?php print($item['object'].' '.$item['client']); ?></div>
        <a <?php if($catId == 4) {print('class="youtube"');} ?> href="<?php print($item['url']); ?>" rel="external" title="<?php print($item['object'].' '.$item['client']); ?>">
            <span class="pictureframe"></span>
        </a>
    </div>
        <?php
        }
    }
    ?>
</div>